using System;
using System.Collections.Generic;
using System.Text;

namespace Jonathan.AlphaGradientPanel
{
    internal class ColorWithAlphaCollectionEditor : System.ComponentModel.Design.CollectionEditor
    {
        private CollectionForm cfForm;

        public ColorWithAlphaCollectionEditor (Type Type)
            : base(Type)
        {
        }

        protected override CollectionForm CreateCollectionForm ()
        {
            cfForm = base.CreateCollectionForm();
            return cfForm;
        }

        public override object EditValue (System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if ((cfForm != null) && cfForm.Visible)
            {
                return new ColorWithAlphaCollectionEditor(CollectionType);
            }
            else
            {
                return base.EditValue(context, provider, value);
            }
        }
    }
}
